﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DDD4Fun.Specification
{
    public class testSpecification
    {
        public static void test()
        {
            var array = Enumerable.Range(-5, 10).ToArray();
            var oddSpec = new OddSpecification();
            var OrWhere = oddSpec.Or(new PositiveSpecification());
            var array2 = array.Where(i => OrWhere.IsSatisfiedBy(i));
            foreach(var item in array.Where(i=>OrWhere.IsSatisfiedBy(i)))
            {
               
                Console.WriteLine(item);
            }
        }

    }


    public class PositiveSpecification : CompositeSpecification<int>
    {
        public override bool IsSatisfiedBy(int candidate)
        {
            return candidate > 0;
        }
    }

    public class OddSpecification : CompositeSpecification<int>
    {
        public override bool IsSatisfiedBy(int candidate)
        {
            return candidate % 2 != 0;
        }
    }


}
